﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ReallyReallyReallySimpleRogueLike;
using ReallyReallyReallySimpleRoguelike;
using ReallyReallyReallySimpleRoguelike.Entities;

namespace ReallyReallyReallySimpleRoguelike.Helpers
{
    public static class SimpleBattle
    {
        //changed to static
        public static void Fight(Player player, IList<Monster> monsters)
        {
            //get the monster on same square as player with the most hits
            Monster monster = monsters.OrderBy(m => m.Hits).FirstOrDefault();
            
            // if the player has a sword kill monster or...
            
            if (player.Inventory.Any<Sword>())
            {
                //use sword - has limited uses
                player.Inventory[0].Use(player); 
                
                //Kill monster
                player.Kill(monster);
                   
            }
            else
            {
                //Kill player
                monster.Kill(player);
            }
        }
    }
}
